//
//  TableViewOneCell.m
//  lx
//
//  Created by 李响 on 15/6/9.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "TableViewOneCell.h"
#import "Table.h"
#import "UIImageView+WebCache.h"
#import "BaseModel.h"

@implementation MyImageView

@end

@implementation TableViewOneCell
-(void)dealloc
{
    [_main release];
    [_oneLabel release];
    [_oneImageView release];
    [_twoLabel release];
    [_threeLabel release];
    [_fourLabel release];
    [_fiveImageView release];
    [_sixImageView release];
    [_sevenImageView release];
    [_eightLabel release];
    [_playImageView release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        //主题label
        self.oneLabel = [[UILabel alloc] init];
        [self.contentView addSubview:self.oneLabel];
        [_oneLabel release];
        //左面图片
        self.oneImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:self.oneImageView];
        [_oneImageView release];
        //多少人关注
        self.twoLabel = [[UILabel alloc] init];
        [self.contentView addSubview:self.twoLabel];
        [_twoLabel release];
        //多少人听
        self.threeLabel = [[UILabel alloc] init];
        [self.contentView addSubview:self.threeLabel];
        [_threeLabel release];
        //主题下面简介
        self.fourLabel = [[UILabel alloc] init];
        [self.contentView addSubview:self.fourLabel];
        [_fourLabel release];
        //人型图片
        self.fiveImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:self.fiveImageView];
        [_fiveImageView release];
        //耳机图片
        self.sixImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:self.sixImageView];
        [_sixImageView release];
        //关注图片
        self.sevenImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:self.sevenImageView];
        [_sevenImageView release];
        //关注字体
        self.eightLabel = [[UILabel alloc] init];
        [self.contentView addSubview:self.eightLabel];
        [_eightLabel release];
        //点击手势图片
        self.playImageView = [[MyImageView alloc] init];
        [self.contentView addSubview:self.playImageView];
        self.playImageView.userInteractionEnabled = YES;
        [_playImageView release];
        
    }
    return self;
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    
    CGFloat width = self.contentView.frame.size.width;
    CGFloat height = self.contentView.frame.size.height;
    //主题label
    self.oneLabel.frame = CGRectMake(width / 4, height / 5, width, height / 6);
    //左面图片
    self.oneImageView.frame = CGRectMake(width / 25, height / 8, width / 6, height / 8 * 6);
    //多少人关注
    self.twoLabel.frame = CGRectMake(width * 7 / 24, height * 5 / 7, width / 4, height / 5);
    //多少人听
    self.threeLabel.frame = CGRectMake(width * 6 / 10 + width / 20, height * 5 / 7, width / 4, height / 5);
    //主题下面简介
    self.fourLabel.frame = CGRectMake(width / 4, height / 2 - 1, width / 3, height / 8);
    //人型图片
    self.fiveImageView.frame = CGRectMake(width * 5 / 21 , height * 5 / 7, width / 20, height / 5);
    //耳机图片
    self.sixImageView.frame = CGRectMake(width * 6 / 10, height * 5 / 7, width / 20, height / 5);
    //关注图片
    self.sevenImageView.frame = CGRectMake(width * 6 / 7, height * 1 / 7, width / 14, height / 3);
    //关注字体
    self.eightLabel.frame = CGRectMake(width * 6 / 7, height * 3 / 7, width / 12, height / 3);
    //点击手势图片
    self.playImageView.frame = CGRectMake(width / 16, height * 1 / 5, width / 8, height / 7 * 4);
    
}
- (void)setMain:(Table *)main
{
    if (_main != main) {
        [_main release];
        _main = [main retain];
    }
    //左面图片
    [self.oneImageView sd_setImageWithURL:[NSURL URLWithString:_main.pic]];
    //主题label
    self.oneLabel.text = _main.rname;
    //字体加粗
    self.oneLabel.font = [UIFont boldSystemFontOfSize:17];
    
    NSString *updateTime = [NSString stringWithFormat:@"%ld", (long)_main.followedNum];
    NSString *listenNum = [NSString stringWithFormat:@"%ld", (long)_main.listenNum];
    //多少人听
    //self.twoLabel.text = updateTime;
    self.twoLabel.text = [BaseModel foucsChangeStringValue:updateTime];
    //多少人关注
    //self.threeLabel.text = listenNum;
    self.threeLabel.text = [BaseModel listenChangeStringValue:listenNum];
    //主题下面简介
    self.fourLabel.text = _main.radioDesc;
    //人型图片
    [self.fiveImageView setImage:[UIImage imageNamed:@"like"]];
    //耳机图片
    [self.sixImageView setImage:[UIImage imageNamed:@"listen"]];
    //关注图片
    [self.sevenImageView setImage:[UIImage imageNamed:@"1"]];
    //关注字体
    self.eightLabel.text = @"关注";
    //字体大小调节
    self.playImageView.image = [UIImage imageNamed:@"bofang.png"];
    //点击手势图片
    self.oneLabel.font = [UIFont systemFontOfSize:15];
    self.twoLabel.font = [UIFont systemFontOfSize:12];
    self.threeLabel.font = [UIFont systemFontOfSize:12];
    self.fourLabel.font = [UIFont systemFontOfSize:12];
    self.eightLabel.font = [UIFont systemFontOfSize:12];
}
- (void)sendIndex:(NSInteger)index section:(NSInteger)section
{
    self.playImageView.index = index;
    self.playImageView.section = section;
}

- (void)sendint:(NSInteger)d
{
    self.playImageView.tag = d;
}

- (void)awakeFromNib {
    // Initialization code
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
